{% extends "base.html" %}

{% import "snippets.html" as snippets with context %}
{% import "utils.html" as utils with context %}

{% set logo = snippets.logo() %}
{% set before_header = snippets.before_header() %}
{% set after_header = snippets.after_header() %}
{% set before_footer = snippets.before_footer() %}
{% set after_footer = snippets.after_footer() %}
{% set license_info = snippets.license_info() %}
{% set creditlogos = snippets.creditlogos() %}
{% set credits = snippets.credits() %}

{% block layout %}

    <div id="moin-main-wrapper">
        {{ before_header }}
        <header id="moin-header">
            {% block header %}
                {% if search_form %}
                    {{ header_search(search_form) }}
                {% endif %}
                {% if logo %}
                    <div id="moin-logo">
                        <a href="{{ url_for('frontend.show_item', item_name=cfg.root_mapping.get('', cfg.default_root)) }}">{{ logo }}</a>
                    </div>
                {% endif %}
                <ul id="moin-username">
                    {{ utils.user_login_logoff() }}
                </ul>
                {% if cfg.sitename %}
                    <a class="moin-sitename" href="{{ url_for('frontend.show_item', item_name=cfg.item_root) }}">
                        {{ cfg.sitename }}
                    </a>
                {% endif %}
                {{ utils.breadcrumbs(theme_supp.path_breadcrumbs, title_name) }}
                {% set navibar_items = theme_supp.navibar(fqname) %}
                {% if navibar_items %}
                    <ul id="moin-navibar" class="panel" data-expanded_quicklinks_size="{{ cfg.expanded_quicklinks_size }}">
                        <li class="moin-panel-heading">{{ _('Navigation') }}</li>
                        {% for cls, url, text, title in navibar_items %}
                            <li class="{{ cls }}">
                                <a href="{{ url }}" {% if title %}title="{{ title }} : {{ url|safe }}"{% else %}title="{{ url|safe }}"{% endif %}>{{ text }}</a>
                            </li>
                        {% endfor %}
                    </ul>
                {% endif %}
                <hr class="moin-pageline" />
                {% block header_itemviews %}{% endblock %}
            {% endblock %}
        </header>
        {{ after_header }}

        <div id="moin-page" role="main" lang="{{ theme_supp.content_lang }}" dir="{{ theme_supp.content_dir }}">
            {% block item -%}
                {# If you want itemviews in your template, extend from show.html, not from here. #}
                <div id="moin-content">
                    <div id="moin-flash">  {# client side javascript may add messages here #}
                        {% for category, msg in get_flashed_messages(with_categories=true) %}
                            <p class="moin-flash moin-flash-{{ category }}">{{ msg }}</p>
                        {% endfor %}
                    </div>
                    {% block content %}
                        {# All content templates should have implement this block. #}
                    {% endblock %}
                </div>
            {%- endblock %}
        </div>

        {{ before_footer }}
        <footer id="moin-footer">
            {% block footer %}
                {% block footer_hr %}<hr/>{% endblock %}
                {% block footer_itemviews %}{% endblock %}
                {% block footer_meta %}{% endblock %}
                {{ creditlogos }}
                {{ credits }}
                {{ license_info }}
            {% endblock %}
        </footer>
        {{ after_footer }}
    </div>
{% endblock %}
